<?php

/**
 * 总后台权限校验
 * @param $adminID
 * @param $authID
 * @return bool
 */
function checkAuth($adminID, $authID)
{
    if (!$adminID) return false;
    if (!$authID) return false;
    $adminInfo = \app\common\model\XkAdmin::where(['id' => $adminID])->find();
    if (!$adminInfo) return false;
    //  如果是超管直接返回不做权限判断
    if ($adminInfo['roleID'] == 0) return true;
    $roleInfo = \app\common\model\XkAdminRole::where(['id' => $adminInfo['roleID']])->find();
    if (!$roleInfo) return false;
    $allAuth = explode(',', $roleInfo['authIDs']);
    return in_array($authID, $allAuth) ? true : false;
}